<admintpl file="header" />
</head>
<body>
<td class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li><a href="{:U('Businessset/pricing_tactics_list/')}">服务策略单管理</a></li>
        <li class="active"><a href="#')">服务策略单修改</a></li>
    </ul>

    <form  id="myform2"  method="post" class="form-horizontal js-ajax-form" action="{:U('Businessset/pricing_tactics_update')}"  method="post">

        <fieldset>
            <input type="hidden" name="pid" value="{$data.pid}">
            <div class="control-group">
                <label class="control-label">城市:</label>
                <div class="controls">
                    <select onchange="CityChanged();" id="city" name="province_id" readonly>
                        <volist name="province_data" id="vo">
                           <!-- <option value="{$vo.id}">{$vo.name}</option>-->
                            <php>if($data['province_id']==$vo['id']){</php>
                            <option name="{$vo.id}" selected="selected" value={$vo['id']}>{$vo['name']}</option>
                            <php>}else{</php>

                            <php>}</php>
                        </volist>



                    </select>
                    <select name="city_id" id="city_id" readonly>
                        <volist name="citys" id="vo" >
                            <php>if($data['city_id']==$vo['cityascii']){</php>
                            <option name="{$vo.city}" selected="selected" value={$vo['cityASCII']}>{$vo['city']}</option>
                            <php>}else{</php>

                            <php>}</php>
                        </volist>
                    </select>
                </div>
                <!-- 里程费配置 -->
                <h4 style="color: #f50">里程费配置</h4>
                <input type="button"  class="btn btn-primary" value="增加" id="addmileage" onClick="add_mileage_Div();" />

                <table id="div_mileage"  class="table table-hover table-bordered table-list">
                    <thead>
                    <tr>
                        <th >标题</th>
                        <th >公里</th>
                        <th >金额</th>
                        <th  >金额标题</th>
                        <th>每公里金额</th>
                    </tr>
                    </thead>
                    <tbody>
                        <foreach name="mileage" item="vo" key="k">
                            <tr >
                                <td><input style="width: 150px;" name="mileage[{$k+1}][title]" type="text" value="{$vo.title}" required/>
                                </td>
                                <td ><input  style="width: 150px;" name="mileage[{$k+1}][kilometre]" type="text" value="{$vo.kilometre}" required/>
                                </td>

                                <td><input  style="width: 150px;" name="mileage[{$k+1}][money]" type="text" value="{$vo.money}"  required/>
                                </td>

                                <td><input  style="width: 150px;" name="mileage[{$k+1}][money_title]" type="text" value="{$vo.money_title}" required/>
                                </td>

                                <td><input  style="width: 150px;" name="mileage[{$k+1}][pricePer]" type="text" value="{$vo.pricePer}"  required/>
                                </td>
                            </tr>
                        </foreach>
                    </tbody>

                    <div class="control-group">

                    </div>
                </table>
                <!-- 排队费用配置 -->
                <h4 style="color: #f50">排队费用配置</h4>
                <input type="button"  class="btn btn-primary" value="增加" id="addline_up" onClick="add_line_up_Div();" />
                <table id="div_line_up" class="table table-hover table-bordered table-list">
                    <thead>
                    <tr>
                        <th>标题</th>
                        <th >时长</th>
                        <th >金额</th>
                        <th >金额标题</th>
                        <th >每小时金额</th>
                    </tr>
                    </thead>
                    <tbody>
                    <foreach name="line_up" item="vo" key="k">
                        <tr >
                            <td><input style="width: 150px;" name="line_up[{$k+1}][title]" type="text"  value="{$vo.title}" required/>
                            </td>

                        <td>
                            <input  style="width: 150px;" name="line_up[{$k+1}][timemin]" type="text" value="{$vo.timemin}" required/>
                        </td>

                        <td>
                            <input style="width: 150px;" name="line_up[{$k+1}][money]" type="text" value="{$vo.money}" required/>
                        </td>

                        <td>
                            <input style="width: 150px;" name="line_up[{$k+1}][money_title]" type="text"  value="{$vo.money_title}" required/>
                        </td>

                        <td>
                            <input style="width: 150px;" name="line_up[{$k+1}][pricePer]" type="text"  value="{$vo.pricePer}" required />
                        </td>
                    </tr>
                    </foreach>
                    </tbody>
                </table>

                <!-- 夜间加价配置 -->
                <h4 style="color: #f50">夜间加价配置</h4>
                <input type="button"  class="btn btn-primary" value="增加" id="addnight" onClick="add_night_Div();" />
                <table id="div_night" class="table table-hover table-bordered table-list">
                    <thead>
                    <tr>
                        <th>标题</th>
                        <th >开始时间</th>
                        <th >结束时间</th>
                        <th >每单加价金额</th>
                        <th >金额描述</th>
                    </tr>
                    </thead>
                    <tbody>
                    <foreach name="night" item="vo" key="k">
                        <tr>
                        <td>
                            <input style="width: 150px;" name="night[{$k+1}][title]" type="text"  value="{$vo.title}"  required/>
                        </td>
                        <td>
                            <input style="width: 150px;" name="night[{$k+1}][startTime]" type="text"  value="{$vo.startTime}" required/>
                        </td>
                        <td>
                            <input style="width: 150px;" name="night[{$k+1}][endTime]" type="text"  value="{$vo.endTime}" required/>
                        </td>
                        <td>
                            <input style="width: 150px;" name="night[{$k+1}][addMoney]" type="text"  value="{$vo.addMoney}" required />
                        </td>
                        <td>
                            <input style="width: 150px;" name="night[{$k+1}][money_title]" type="text"  value="{$vo.money_title}"  required/>
                        </td>
                    </tr>
                        </foreach>
                    </tbody>
                </table>
                <!-- 临时加价配置 -->
                <h4 style="color: #f50">临时加价配置</h4>
                <div id="div_temporary" >
                        <div>
                        加价金额：<input name="temporary[addtimes]" type="text"   value="{$temporary.addtimes}" required/>
                        </div>
                    <div>&nbsp;</div>
                    <div class="control-group">
                        加价原因：<textarea name="temporary[addtimes_reson]" cols="20" rows="5">{$temporary.addtimes_reson}</textarea>
                    </div>
                </div>

                <!-- 起步价冗余字段 -->
                <h4 style="color: #f50">起步价冗余字段</h4>
                <input type="button"  class="btn btn-primary" value="增加" id="addstarting_price" onClick="add_starting_price_Div();" />
                <table id="div_is_starting_price" class="table table-hover table-bordered table-list">
                    <thead>
                    <tr>
                        <th>起步公里数</th>
                        <th >金额</th>
                        <th >起步时间</th>
                        <th >金额</th>
                    </tr>
                    </thead>
                    <tbody>
                    <foreach name="is_starting_price" item="vo" key="k">
                        <tr>
                            <td>
                                <input style="width: 200px;" name="is_starting_price[{$k+1}][mileageKilometre]" type="text"   value="{$vo.mileageKilometre}" required/>公里
                            </td>
                            <td>
                                <input style="width: 200px;" name="is_starting_price[{$k+1}][mileageMoney]" type="text"  value="{$vo.mileageMoney}" required/>元
                            </td>
                            <td>
                                <input style="width: 200px;" name="is_starting_price[{$k+1}][lineTime]" type="text"  value="{$vo.lineTime}"  required/>分钟
                            </td>
                            <td>
                                <input style="width: 200px;" name="is_starting_price[{$k+1}][lineKoney]" type="text"  value="{$vo.lineKoney}" required/>元
                            </td>
                        </tr>
                    </foreach>
                    </tbody>
                </table>
            </div>

        </fieldset>
        <div class="form-actions">
            <button type="submit" class="btn btn-primary js-ajax-submit">{:L('SAVE')}</button>
            <a class="btn" href="{:U('Businessset/pricing_tactics_list')}">{:L('BACK')}</a>
        </div>
    </form>
</div>
<script src="__PUBLIC__/js/common.js"></script>
<script>
    function CityChanged(province_id){
        alert(province_id);
        $.ajax({
            url:"{:U('Operation/location_api')}",
            data:"province_id="+$("#city").val(),
            dataType:"JSON",
            success:function(ret){

                cmbAddOption(ret.retValue);
            }
        });
    }

    function cmbAddOption(ret)
    {
        $("#city_id").empty();
        var opetion = null;
        for(var i =0; i<ret.length;i++){
            opetion+= '<option value="'+ret[i].id+'">'+ret[i].city+'</option>';
        }
        $("#city_id").append(opetion);
    }

    var mileage_count = 100;
    function add_mileage_Div(){
        var div ="新增：<tr >"+
                            "<td><input style=\"width: 150px;\" name=\"mileage["+mileage_count+"][title]\" type=\"text\" required/>"+
                            "</td>"+
                            "<td ><input  style=\"width: 150px;\" name=\"mileage["+mileage_count+"][kilometre]\" type=\"text\" required/>"+
                            "</td>"+

                            "<td><input  style=\"width: 150px;\" name=\"mileage["+mileage_count+"][money]\" type=\"text\"   required/>"+
                            "</td>"+

                            "<td><input  style=\"width: 150px;\" name=\"mileage["+mileage_count+"][money_title]\" type=\"text\"  required/>"+
                            "</td>"+

                            "<td><input  style=\"width: 150px;\" name=\"mileage["+mileage_count+"][pricePer]\" type=\"text\"  required/>"+
                            "</td>"+
                    "</tr>";

        $('#div_mileage').append(div);
        mileage_count++;
    };

    var line_up_count = 100;
    function add_line_up_Div(){
        var div ="新增：<tr><td>"+
                "<input style=\"width: 150px;\"  name=\"line_up["+line_up_count+"][title]\" type=\"text\" required/>"+
                "</td>"+
                "<td>"+
                "<input style=\"width: 150px;\" name=\"line_up["+line_up_count+"][timemin]\" type=\"text\" required/>"+
                "</td>"+
                "<td>"+
                "<input style=\"width: 150px;\" name=\"line_up["+line_up_count+"][money]\" type=\"text\" required/>"+
                "</td>"+
                "<td>"+
                "<input style=\"width: 150px;\" name=\"line_up["+line_up_count+"][money_title]\" type=\"text\"  required/>"+
                "</td>"+
                "<td>"+
                "<input style=\"width: 150px;\" name=\"line_up["+line_up_count+"][pricePer]\" type=\"text\" required/>"+
                "</td>"+
                "</tr>";

        $('#div_line_up').append(div);
        line_up_count++;
    };

    //夜间加价
    var night_count = 100;
    function add_night_Div(){
        var div ="新增：<tr>"+
                "<td>"+
                "<input style=\"width: 150px;\" name=\"night["+night_count+"][title]\" type=\"text\" required/>"+
                "</td>"+
                "<td>"+
                "<input style=\"width: 150px;\" name=\"night["+night_count+"][startTime]\" type=\"text\" required/>"+
                "</td>"+
                "<td>"+
                "<input style=\"width: 150px;\" name=\"night["+night_count+"][endTime]\" type=\"text\" required/>"+
                "</td>"+
                "<td>"+
                "<input style=\"width: 150px;\" name=\"night["+night_count+"][addMoney]\" type=\"text\"  required/>"+
                "</td>"+
                "<td>"+
                "<input style=\"width: 150px;\" name=\"night["+night_count+"][money_title]\" type=\"text\" required/>"+
                "</td>"+
                "</tr>";

        $('#div_night').append(div);
        night_count++;
    };
    //起步价
    var starting_price_count = 100;
    function add_starting_price_Div(){
        var div ="新增：<tr>"+
                "<td>"+
                "<input style=\"width: 200px;\" name=\"is_starting_price["+starting_price_count+"][mileageKilometre]\" type=\"text\" required/>公里"+
                "</td>"+
                "<td>"+
                "<input style=\"width: 200px;\" name=\"is_starting_price["+starting_price_count+"][mileageMoney]\" type=\"text\" required/>元"+
                "</td>"+
                "<td>"+
                "<input style=\"width: 200px;\" name=\"is_starting_price["+starting_price_count+"][lineTime]\" type=\"text\" required/>分钟"+
                "</td>"+
                "<td>"+
                "<input style=\"width: 200px;\" name=\"is_starting_price["+starting_price_count+"][lineKoney]\" type=\"text\"  required/>元"+
                "</td>"+
                "</tr>";

        $('#div_is_starting_price').append(div);
        starting_price_count++;
    };
</script>
</body>
</html>